package edu.sdwu.liqing.qasystem.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import edu.sdwu.liqing.qasystem.annotation.HasRole;
import edu.sdwu.liqing.qasystem.annotation.Login;
import edu.sdwu.liqing.qasystem.entity.QaRole;
import edu.sdwu.liqing.qasystem.model.Response;
import edu.sdwu.liqing.qasystem.service.IQaRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *   前端控制器
 * </p>
 *
 * @author liqing@sdwu.edu
 * @since 2020-03-22
 */
@RestController
@RequestMapping("api/qa-role")
public class QaRoleController {

    @Autowired
    IQaRoleService roleService;


    @Login
    @GetMapping("list")
    public Response<List<QaRole>> getList() {
        return Response.ok(roleService.list());
    }

    /**
     * 这个逻辑还没写 ，暂时先放一放
     * */
    @PostMapping
    @HasRole({"ADMIN"})
    public Response<String> save(@RequestBody QaRole role) {
        roleService.save(role);
        return Response.ok("success");
    }

    @PutMapping
    @HasRole({"ADMIN"})
    public Response<String> update(@RequestBody QaRole role) {
        return Response.ok("success");
    }

    @DeleteMapping("{id}")
    @HasRole({"ADMIN"})
    public Response<String> delete(@PathVariable("id") String id) {
        return Response.ok("success");
    }

}

